package com.duckygo.towerdefense.game.sprites;

import java.util.Hashtable;


import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;

import com.duckygo.towerdefense.game.scenes.TowerDefenseScene;
import com.duckygo.towerdefense.game.sprites.AnimatedSprite2D.AnimationTemplate;

public class Explosion extends AnimatedSprite2D implements AnimationListener {


	private static Hashtable<String, AnimationTemplate> animations = new Hashtable<String, AnimationTemplate>();

	static {
		Explosion xplo = new Explosion(null);
		xplo.registerAnimation("bang", 10, 8, 0, 0);
	}

	
	@Override
	protected Hashtable<String, AnimationTemplate> getAnimations() {
		return animations;
	}
	
	
	public Explosion(Projectile project) {
		texture = TowerDefenseScene.EXPLOSION_TEX;
		width = 64;
		height = 64;
		
		if (project != null) {
			project.parent.removeChild(project);
			
			x = project.x;
			y = project.y;
		}
		
		if (getAnimations().size() > 0) {
			play("bang", false).listener = this;
		}
	}


	@Override
	public void onAnimationEnd(Animation animation) {
		parent.removeChild(this);
	}


	@Override
	public void onAnimationRepeat(Animation animation) {
	}


	@Override
	public void onAnimationStart(Animation animation) {
	}
}
